﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Cofe.Core;
using Cofe.Core.Security;
using Cofe.Core.Validater;
using Cofe.Web;

namespace Cofe.Data
{
    /// <summary>
    /// {300-319} A list of properties for Database Internal uses.
    /// </summary>
    [PropertyId(300, 319)]
    public enum DatabaseProperties 
    {
        /// <summary>
        /// Return the database entry (for entity framework) associated to current entry.
        /// </summary>
        DatbaseEntry = 300,

        /// <summary>
        /// Write the entry to repository, calls IRepository.AddOrUpdate(clone of currentEntry)
        /// UpdateSubEntries - If true, load next level and write to database (using AddOrUpdate) as well.
        /// </summary>
        [Action(ActionType.Async, "UpdateSubEntries", "Recursive")]
        [HandleOnes(HandleOnceActionMode.Compulsory)]
        [RequirePermission(PermissionType.Read)]
        [Alias("WriteRepository")]        
        WriteRepositoryAsync
    }

    /// <summary>
    /// {320-329} A list of properties for User feedback
    /// </summary>
    [PropertyId(320, 329)]
    public enum UserFeedbackProperties
    {
        /// <summary>
        /// Sets or gets descrription of an entry, can be set by anyone who can write the entry.
        /// </summary>
        [PropertyType(typeof(string))]
        [WebProperty(PropertyXmlType.Element)]
        [Alias("Description")]
        Description = 320, 

        /// <summary>
        /// Gets all tags of current entry, comma delimited.
        /// </summary>
        [PropertyType(typeof(string))]
        [WebProperty(PropertyXmlType.Element)]
        [Alias("Tags")]
        Tags,

        [Action(ActionType.Sync, "TagNames")]
        [HandleOnes]
        [RequirePermission(PermissionType.Write)]
        [WebAction(WebAccessType.Action, RelationType.AddTag, false)]
        [Alias("AddTag")]
        AddTag,

        [Action(ActionType.Sync, "TagNames")]
        [HandleOnes]
        [RequirePermission(PermissionType.Write)]
        [WebAction(WebAccessType.Action, RelationType.RemoveTag, false)]
        [Alias("RemoveTag")]
        RemoveTag
    }
}
